import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class ListDemo extends StatelessWidget {
  final _items = 'abcdefghijklmnopqrstuvwxyz'
      .split('')
      .map((str) => Center(
            heightFactor: 1.5,
            child: Text(
              str.toUpperCase(),
              textScaleFactor: 2,
              style: TextStyle(color: Colors.black45),
            ),
          ))
      .toList();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('基础List示例'),
        centerTitle: true,
      ),
      body: Column(
        children: <Widget>[
          //固定表头-悬浮
          ListTile(title: Text('商品列表')),
          //分割线
          Divider(
            height: 0.5,
            //分割线高度（效果是距离上面的距离）
            color: Colors.grey[300],
            indent: 15,
            //左边距
            endIndent: 15,
            //右边距
            thickness: 0.5, //厚度（线条粗）
          ),
          //在弹性布局中，可以使用Expanded自动拉伸组件大小
          //解决ListView高度边界确定引起的异常
          Expanded(
            child: ListView(
              physics: BouncingScrollPhysics(),
              children: <Widget>[
                ListTile(
                  leading: Icon(Icons.access_time),
                  title: Text('Time'),
                ),
                ListTile(
                  leading: Icon(Icons.add_call),
                  title: Text('Call'),
                ),
                ListTile(
                  leading: Icon(Icons.account_circle),
                  title: Text('Circle'),
                ),
                ListTile(
                  leading: Icon(Icons.airplay),
                  title: Text('Airplay'),
                ),
              ]..addAll(_items),
            ),
          ),
        ],
      ),
    );
  }
}
